package sllvm;

public class Table
{
	private String id;
	private int value;
	private Table tail;
	
	public Table(String id, int value)
	{
		this.id = id;
		this.value = value;
		this.tail = null;
	}	
	
	public int lookup(String id) throws Exception
	{
		Table t = this;
		
		while (t != null)
		{
			if (t.id == id)
				return t.value;
			
			t = t.tail;
		}
		
		throw new Exception("Não existe id \""+ id +"\" na tabela.");
	}
	
	public Table update(String id, int value)
	{
		Table t = new Table(id, value);
		t.tail = this;
		
		return t;
	}
}
